package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * 大攻略
 */
@Getter
@Setter
public class Strategy {

    public static final Integer STATE_NORMAL = 0;  //正常状态
    public static final Integer STATE_HOT = 1;     //推荐状态
    public static final Integer STATE_DISABLE = 2; //禁用状态

    private Long id;
    //攻略所属地区
    private Region place;
    //攻略标题
    private String title;
    //攻略副标题
    private String subTitle;
    //攻略封面
    private String coverUrl;
    //攻略状态
    private Integer state = STATE_NORMAL; //默认正常状态

    public String getStateDisplay() {

        if (state == STATE_NORMAL) {
            return "正常状态";
        } else if (state == STATE_HOT) {
            return "推荐状态";
        } else if (state == STATE_DISABLE) {
            return "禁用状态";
        }
        return "";
    }

    public String getJsonString() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("subTitle", subTitle);
            map.put("coverUrl", coverUrl);
        if (place != null) {
            map.put("placeId", place.getId());
        }
        map.put("state", state);
        return JSONUtil.toJsonString(map);
    }


}